(
    function (factory) {
      if (typeof define === "function" && define.amd) {

        // AMD. Register as an anonymous module.
        define(["jquery", "./version"], factory);
      } else {

        // Browser globals
        factory(jQuery);
      }
    }
    (
        function($){

          var charts_compare = function () {
            function init(){

              var charts_compare = echarts.init(document.getElementById('compare'));
              var charts_year = echarts.init(document.getElementById('year'))

              var libAnalysis = echarts.init(document.getElementById("library-analysis"));
              var dorm1Analysis = echarts.init(document.getElementById('dorm1-analysis'));
              var dorm2Analysis = echarts.init(document.getElementById('dorm2-analysis'));
              var officeAnalysis = echarts.init(document.getElementById('office-analysis'));

              var lighting_compare = echarts.init(document.getElementById("lighting-compare"));

              var lighting_efficiency = echarts.init(document.getElementById("lighting-efficiency"));

              option_compare = {
                tooltip : {
                  trigger: 'axis',
                  axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                    type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                  }
                },
                legend: {
                  data: ['照明系统', '空调系统']
                },
                grid: {
                  left: '3%',
                  right: '4%',
                  bottom: '3%',
                  containLabel: true
                },
                yAxis:  {
                  type: 'value'
                },
                xAxis: {
                  type: 'category',
                  data: [11.26, 11.27, 11.28, 11.29, 11.30, 12.1, 12.2, 12.3, 12.4, 12.5]
                },
                series: [
                  {
                    name: '照明系统',
                    type: 'bar',
                    stack: '总量',
                    label: {
                      normal: {
                        show: false,
                        // position: 'insideCenter'
                      }
                    },
                    data: [120, 132, 101, 134, 90, 230, 210, 280, 130, 185]
                  },
                  {
                    name: '空调系统',
                    type: 'bar',
                    stack: '总量',
                    label: {
                      normal: {
                        show: false
                      }
                    },
                    data: [220, 182, 191, 234, 290, 330, 310,120, 132, 101]
                  }
                ]
              };

              option_year = {
                tooltip: {
                  trigger: 'axis',
                  axisPointer: {
                    type: 'shadow'
                  }
                },
                legend: {
                  data: ['2016年', '2017年']
                },
                grid: {
                  left: '3%',
                  right: '4%',
                  bottom: '3%',
                  containLabel: true
                },
                xAxis: {
                  type: 'value',
                  boundaryGap: [0, 0.01]
                },
                yAxis: {
                  type: 'category',
                  data: ['图书馆','宿舍区1','宿舍区2','办公楼','总耗电量(千瓦时)']
                },
                series: [
                  {
                    name: '2016年',
                    type: 'bar',
                    data: [58203, 23489, 29034, 104970, 230230],
                    // label: {
                    //   normal: {
                    //     show: true,
                    //     position: 'insideRight'
                    //   }
                    // },
                  },
                  {
                    name: '2017年',
                    type: 'bar',
                    data: [69325, 23438, 31000, 134141, 261807],
                    // label: {
                    //   normal: {
                    //     show: true,
                    //     position: 'insideRight'
                    //   }
                    // },
                  }
                ]
              };

              lighting_pie =  {
                title : {
                  text: '照明系统用电总量区域分布',
                },
                tooltip : {
                  trigger: 'item',
                  formatter: "{a} <br/>{b} : {c} ({d}%)"
                },
                legend: {
                  orient: 'horizontal',
                  left: 'right',
                  data: ['图书馆','宿舍楼1','办公楼','宿舍楼2']
                },
                series : [
                  {
                    name: '区域耗电分布',
                    type: 'pie',
                    radius : ['40%','70%'],
                    innerRadius:'30%',
                    center: ['50%', '60%'],
                    data:[
                      {value:335, name:'图书馆'},
                      {value:310, name:'宿舍楼1'},
                      {value:234, name:'办公楼'},
                      {value:252, name:'宿舍楼2'},
                    ],
                    itemStyle: {
                      emphasis: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                      }
                    }
                  }
                ]
              };

              opt_lightEfficiency = {
                tooltip : {
                  trigger: 'axis',
                  axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                    type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                  }
                },
                legend: {
                  data: ['照明系统', '空调系统']
                },
                grid: {
                  left: '3%',
                  right: '4%',
                  bottom: '3%',
                  containLabel: true
                },
                yAxis:  {
                  type: 'value',
                  name: 'KW*H/m2',
                  data: [
                    {
                      name: 'Y 轴值为 100 的水平线',
                      yAxis: 100
                    }
                  ]
                },
                xAxis: {
                  type: 'category',
                  data: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
                  name:'月份'
                },
                series: [
                  {
                    name: '照明系统',
                    type: 'bar',
                    stack: '总量',
                    label: {
                      normal: {
                        show: false,
                        // position: 'insideCenter'
                      }
                    },
                    data: [120, 132, 101, 134, 90, 230, 210, 280, 130, 185, 236, 188],
                    markLine : {
                      lineStyle: {
                        normal: {
                          type: 'solid',
                          width: '2',
                          color: '#1E90FF'
                        }
                      },
                      label:{
                        normal:{
                          position:'end'
                        }
                      },

                      data : [

                        {name:'555',
                          yAxis: 150},

                      ]
                    }
                  },
                ]
              };




              charts_compare.setOption(option_compare);
              charts_year.setOption(option_year);

               libAnalysis.setOption(option_compare);
               dorm1Analysis.setOption(option_compare);
               dorm2Analysis.setOption(option_compare);
               officeAnalysis.setOption(option_compare);

              lighting_compare.setOption(lighting_pie);
              lighting_efficiency.setOption(opt_lightEfficiency);

            }

            this.init = init;
          }

          var compareInit=function () {
            var charts = new charts_compare()
            charts.init()
          }
          $(compareInit)

        }
    )
)